#ifndef _CIBLE
#define _CIBLE

#include <vector>



#define LARGEUR_FENETRE 640
#define HAUTEUR_FENETRE 480

const int BPP = 16;

const int spriteNb = 100;

// ATTENTION : aucune gestion des textures
GLuint GLLoadTexture(char *filename);


struct Rect {
    int x, y;
    int w, h;
    Rect(int _x = 0, int _y = 0, int _w = 0, int _h = 0):
        x(_x), y(_y), w(_w), h(_h)
    { }
};

struct Tile {
    Rect rect;
    Rect clip;
    GLuint texture;
    ~Tile() {
        glDeleteTextures(1, &texture);
    }
};

class Animation
{
private:
    std::vector<Rect> animation;
    std::vector<int> delay;
    int timer;
    int index;
    bool loop;
    bool looping;
public:
    Animation() {
        index = 0;
        timer = SDL_GetTicks();
        loop = false;
        looping = false;
    }
    void Add(int x, int y, int w, int h, int delay);
    void Loop(bool);
    Rect Next();
};


class Sprite
{
private:
    Tile tile;
    Animation animation;

public:
    void Draw();
    void Draw(int x, int y);
    void LoadTexture(char *filename, int width, int height);
    void AddAnimation(int x, int y, int w, int h, int delay = 100);
    void SetPosition(int x, int y);
    void SetX(int x) { tile.rect.x = x; }
};

void animationSprite ();

#endif
